
import axios from 'axios';

/**
 * 商品
 */
export class CommodityService {
    // 分页查询列表
    static findCommoditys (queryParams) {
        return axios({
            url: '/mall/good/Commodity/findCommoditys',
            method: 'POST',
            data: queryParams
        });
    }

    //根据ID查询指定的商品
    static findCommodity (commodityId) {
        const query = {
            commodityId
        }
        return axios({
            url: '/mall/good/Commodity/findCommodity',
            method: 'POST',
            params: query,
        });
    }

    //根据ID查询指定的商品(包含外键名称)
    static findCommodityForView (commodityId) {
        const query = {
            commodityId
        }
        return axios({
            url: '/mall/good/Commodity/findCommodityForView',
            method: 'POST',
            params: query,
        });
    }

    //根据ID查询指定的商品(包含外键名称)
    static findCommodityForEdit (commodityId) {
        const query = {
            commodityId
        }
        return axios({
            url: '/mall/good/Commodity/findCommodityForEdit',
            method: 'POST',
            params: query,
        });
    }

    //根据ID查询指定的商品(只提取ID 和 Name)
    static findCommoditysWithIdNameById (commodityId) {
        const query = {
            commodityId
        }
        return axios({
            url: '/mall/good/Commodity/findCommoditysWithIdNameById',
            method: 'POST',
            params: query,
        });
    }

    //根据名称查询商品集合(只提取ID 和 Name)
    static findCommoditysWithIdNameByName (commodityName) {
        const query = {
            commodityName
        }
        return axios({
            url: '/mall/good/Commodity/findCommoditysWithIdNameByName',
            method: 'POST',
            params: query,
        });
    }

    //新增保存商品
    static saveCommodity (commodity) {
        const query = {}
        return axios({
            url: '/mall/good/Commodity/saveCommodity',
            method: 'POST',
            params: query,
            data: commodity
        });
    }

    //修改保存商品
    static updateCommodity (commodity) {
        const query = {}
        return axios({
            url: '/mall/good/Commodity/updateCommodity',
            method: 'POST',
            params: query,
            data: commodity
        });
    }

    //根据ID查询指定的商品(只提取ID 和 Name)
    static deleteCommodity (commodityId) {
        const query = {
            commodityId
        }
        return axios({
            url: '/mall/good/Commodity/deleteCommodity',
            method: 'POST',
            params: query,
        });
    }
    static getCode(){
      return axios({
        url: '/generatorCode',
        method: 'GET',
      });
    }
    static synchronousAllData(){
      return axios({
        url: '/mall/good/Commodity/synchronousAllData',
        method: 'POST',
      });
    }
}
